//
//  HDTabBarItem.m
//  AccountEasy
//
//  Created by mac on 2020/7/22.
//  Copyright © 2020 AccountEasy. All rights reserved.
//

#import "HDTabBarItem.h"

@implementation HDTabBarItem

+ (instancetype)tabBarItemWithTitle:(NSString *)title normalImg:(NSString *)normalImg selectImg:(NSString *)selectImg{
    
    HDTabBarItem *item = [HDTabBarItem new];
    item.titleLabel.font = kFont(12);
    [item setTitleColor:kGrayColor forState:UIControlStateNormal];
    [item setTitleColor:kColor(109, 135, 243, 1) forState:UIControlStateSelected];
    [item setTitle:title forState:UIControlStateNormal];
    [item setImage:[UIImage imageNamed:normalImg] forState:UIControlStateNormal];
    [item setImage:[UIImage imageNamed:selectImg] forState:UIControlStateSelected];
    item.titleLabel.textAlignment = NSTextAlignmentCenter;
    item.imageView.contentMode = UIViewContentModeCenter;
    item.backgroundColor = kColor(255, 255, 255, 1);
    
    return item;
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imageX = 0;
    CGFloat imageY = kScaleNum(5);
    CGFloat imageW = self.width;
    CGFloat imageH = kScaleNum(25);
    return CGRectMake(imageX, imageY, imageW, imageH);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat titleX = 0;
    CGFloat titleY = kScaleNum(33);
    CGFloat titleW = self.width;
    CGFloat titleH = kScaleNum(15);
    return CGRectMake(titleX, titleY, titleW, titleH);
}

@end
